package com.welkom.everydate.services.implementations;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.welkom.everydate.dao.UserDao;
import com.welkom.everydate.domain.User;
import com.welkom.everydate.services.interfaces.UserService;
import com.welkom.everydate.util.MD5;
@Service
public class UserServiceImpl implements UserService {
	@Resource
	private UserDao userDao;
	@Override
	public User getUserByUserName(String userName) {
		// TODO Auto-generated method stub
		return userDao.getUserByUserName(userName);
	}

	@Override
	public User getUserByUserId(long userId) {
		// TODO Auto-generated method stub
		return userDao.getUserById(userId);
	}

	@Override
	public List<User> queryUserByPage(User user, int startIndex, int pageSize) {
		// TODO Auto-generated method stub
		return userDao.queryUserByPage(user, startIndex, pageSize);
	}

	@Override
	public void updateUser(User user) {
		// TODO Auto-generated method stub
		user.setUserPassword(MD5.getMD5ofStr(user.getPassword()));
		userDao.updateUser(user);
	}

	@Override
	public void addUser(User user) {
		// TODO Auto-generated method stub
		user.setUserPassword(MD5.getMD5ofStr(user.getPassword()));
		userDao.addUser(user);
	}

	@Override
	public void deleteUser(long userId) {
		// TODO Auto-generated method stub
		userDao.removeUserById(userId);
	}
	@Override
	public int getUserTotalCountByCondition(User user){
		return userDao.getTotalCountByCondition(user);
	}

	@Override
	public List<User> getAllUsers() {
		// TODO Auto-generated method stub
		return userDao.getAllUsers();
	}

}
